<template>
  <ul class="type-switch-component">
    <li v-for="(item, index) in list" :key="index" class="type-switch-item" :class="{active: activeIndex === index}" @click="changeActiveIndex(index)">{{ item }}</li>
  </ul>
</template>

<script>
export default {
  data() {
    return {
      list: ["全部考试模拟", "听力", "口语", "阅读", "写作"],
      activeIndex: 0
    };
  },
  methods: {
      changeActiveIndex(index) {
          this.activeIndex = index;
          this.$emit('changeIndex', index);
      }
  }
};
</script>

<style lang="less" scoped>
.type-switch-component {
  line-height: 23px;
  display: flex;
  padding-top: 16px;
  margin-bottom: 14px;
  color: #9da3ac;
  font-size: 16px;
  margin-left: 43px;
  .type-switch-item {
    flex: none;
    &.active {
      color: #3d475c;
    }
  }
  .type-switch-item + .type-switch-item {
    margin-left: 15px;
  }
}
</style>